#include <func.h>

void* pthread_func(void* p)
{
    int fd=*(int*)p;
    close(fd);
    printf("i am child thread!\n");
}
int main()
{
    pthread_t pthid;
    int fd=open("file",O_RDWR);
    ERROR_CHECK(fd,-1,"open")
    int ret=pthread_create(&pthid,NULL,pthread_func,&fd);
    THREAD_ERROR_CHECK(ret,"pthread_create")
    sleep(1);
    printf("i am main thread!\n");
    char buf[128]={0};
    ret=read(fd,buf,sizeof(buf));
    ERROR_CHECK(ret,-1,"read")
    printf("i am main thread retr=%d,get=%s",ret,buf);
    return 0;
}